package com.wangshen.administrator.ygqq.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import com.wangshen.administrator.ygqq.R;
import com.wangshen.administrator.ygqq.bean.AllGoodsBean;

import java.util.List;

/**
 * Created by Administrator on 2016/7/26.
 */
public class ExpandLvAdapter extends BaseExpandableListAdapter {
    private List<AllGoodsBean.AllClassArrayBean> mList;
    private Context mContext;
    public ExpandLvAdapter(Context context , List<AllGoodsBean.AllClassArrayBean> list){
        this.mContext = context;
        this.mList = list;
    }
    @Override
    public int getGroupCount() {
        return mList==null?0:mList.size();
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return 0;
    }

    @Override
    public Object getGroup(int groupPosition) {
        return mList.get(groupPosition);
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return null;
    }

    @Override
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return 0;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.item_all_expandlist, parent, false);
    }
        TextView tv_group = (TextView) convertView.findViewById(R.id.tv_expandlist);
        tv_group.setText(mList.get(groupPosition).getName());
        return convertView;

    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        return null;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }

    public void setData(List<AllGoodsBean.AllClassArrayBean> list){
        this.mList = list;
        notifyDataSetChanged();
    }
}
